<!DOCTYPE html>
<HTML lang="en">
<HEAD>
    <title> The Baby X resource compiler source files </title>
    <meta charset="UTF-8">
        
    <link href="prism.css" rel="stylesheet">
<script src="microlight.js"> </script>
<script src="prism.js"> </script>
<style>
.microlight {
    font-family : monospace;
    white-space : pre;
    background-color : white;
}
    
BODY {
    width:50em;
    margin-left:5em;
    background-color:#c0c0ff;
}

P {
   width : 50em;
}

pre {
   background-color:white;
}
</style>
</HEAD>



<BODY>
    <script src="prism.js"></script>
    <A href ="https://github.com/MalcolmMcLean"> <IMG src = "Cartoon_Owl_clip_art.png" alt="Malcolm's github site">  </A>
    <A href ="index.html"> <IMG src = "babyxrc_logo.svg" alt="Baby X Resource compiler" width = "64" height = "62">  </A>
    &nbsp;&nbsp;
    <IMG src = "babyxrc-banner.svg" width = "256" height = "62" alt = "Baby X RC banner">
<H1> The Baby X resource compiler source files </H1>
<H3> Source file list </H3>
<UL>
<LI> aifffile.c </LI>
    <LI> asciitostring.c - AIFF file loader </LI>
    <LI> babyxrcmain.c - program main function </LI>
    <LI> bbx_utf8.c - UTF-8 utility functions</LI>
    <LI> bdf2c.c - BDF font converter</LI>
    <LI> bmp.c - bitmap file loader / saver</LI>
    <LI> csv.c - comma-separated values file loader</LI>
    <LI> dumpcsv.c - outputs csv file as C source </LI>
    <LI> gif.c - GIF file loader / saver </LI>
    <LI> jpeg.c - JPEG file loader</LI>
    <LI> loadasutf8.c - loads text files as UTF-8 </LI>
    <LI> loadcursor.c - Microsoft CUR file loader </LI>
    <LI> loadimage.c - high level image loader</LI>
    <LI> loadmp3.c - loads MP3 files as raw audio</LI>
    <LI> loadtiff.c - TIFF file loader </LI>
    <LI> lodepng.c - PNG file loader / saver</LI>
    <LI> minimp3.c - MP3 decoder</LI>
    <LI> options.c - commandline option parser</LI>
    <LI> rbtree.c - red black tree </LI>
    <LI> resize.c - image resizing functions</LI>
    <LI> savejpeg.c - JPEG file saver </LI>
    <LI> text_encoding_detect.c - detects encoding of a text file</LI>
    <LI> ttf2c.c - true type font converter </LI>
    <LI> wavfile.c - WAV audio file loader / saver</LI>
    <LI> xmlparser.c - XML file loader</LI>
    <LI> nanosvg.h - SVG file parser </LI>
    <LI> nanosvgrast.h - SVG file rasterizer </LI>
    <LI> freetype/ - code to manipulate truetype fonts</LI>
    <LI> samplerate/ - code to resample audio</LI>
</UL>
    
    <H3> aifffile.c </H3>
    <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load an AIFF file. It loads 16 bit uncompresed AIFF files only.
        However it does support big-endian AIFF files, which are technically AIFC
        files.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        short *loadaiff(const char *fname, long *samplerate, int *Nchannels, long
            *Nsamples);
        short *floadaiff(FILE *fp, long *samplerate, int *Nchannels, long
            *Nsamples);
        </code></pre>
        <P>
        <code>loadaiff</code> - loads an AIFF file in 16-but itnerleaved PPM format.
        </P>
        <P>
        <code>floadaiff</code> - the same fucntion but taking an open stream as an argument.
        </P>
        <HR>
        <H3> asciitostring.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Converts an ASCII string to an escaped C string suitable for using in C
        source code.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        char *fslurp(FILE *fp);
        int validcstring(const char *str);
        char *texttostring(const char *str);
        </code></pre>
        <P>
        <code>fslurp</code> Probably shouldn't be in here. Loads a text file from a stream.
        </P>
        <P>
        <code>validcstring</code> Test if a string is a valid escaped C literal.
        </P>
        <P>
        <code>texttostring</code> Escapes text and returns a C string literal enclosed
        in quotes. If the string is long it will be broken up into separate quoted
        sections separated by newlines.
        </P>
        <HR>
        <H3> babyxrcmain.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        The main function of the Baby X resource compiler.
        </P>
        <HR>
        <H3> bbx_utf8.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Utility functions for manipulating UTF-8. Taken from Baby X.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        int bbx_isutf8z(const char *str);
        int bbx_utf8_skip(const char *utf8);
        int bbx_utf8_getch(const char *utf8);
        int bbx_utf8_putch(char *out, int ch);
        int bbx_utf8_charwidth(int ch);
        int bbx_utf8_Nchars(const char *utf8);
        </code></pre>
        <P>
        <code>bbx_isutf8z</code> - test if a string is valid UTF-8.
        </P>
        <P>
        <code>bbx_utf8_skip</code> - get the number of bytes to skip to move to the next Unicode code point.
        </P>
        <P>
        <code>bbx_utf8_getch</code> - get the Unicode code point at the front of the UTF-8 buffer.
        </P>
        <P>
        <code>bbx_utf8_putch</code> - write a code point to a UTF-8 buffer. Returns the number of bytes written.
        </P>
        <P>
        <code>bbx_utf8_charwidth</code> - get the number of UTF-8 bytes needed to represent a Unicode code point.
        </P>
        <P>
        <code> bbx_utf8_Nchars</code> - get the number of Unicode code points in a UTF-8 nul-terminated buffer.
        </P>
        <P>
        See <A href="usingutf8.html"> using UTF-8</A>.
        </P>
        <HR>
        <H3> bdf2c.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        This code loads a .bdf font and converts it to a bitmap_font structure.
        </P>
        <pre><code class="language-c">
        void ReadBdf(FILE * bdf, FILE * out, int header, const char *name);
        </code></pre>
        <P>
        <code>ReadBdf</code> - a misnomer. It reads a BDF font from a stream, and writes C source to out. Pass header = true to just write the C header, and name for the name of the bitmap_font structure.
        </P>
        <HR>
        <H3> bmp.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load and save Microsoft bitmap .bmp files. It won't support absolutely everything (no compressed bitmaps or ones with odd channel masks). However it should load most bitmaps encountered in practice. There are also functions to save.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        int bmpgetinfo(char *fname, int *width, int *height);
        unsigned char *loadbmp(char *fname, int *width, int *height);
        unsigned char *loadbmp8bit(char *fname, int *width, int *height,
            unsigned char *pal);
        unsigned char *loadbmp4bit(char *fname, int *width, int *height,
            unsigned char *pal);
        int savebmp(char *fname, unsigned char *rgb, int width, int height);
        int savebmp8bit(char *fname, unsigned char *data, int width, int height,
            unsigned char *pal);
        int savebmp4bit(char *fname, unsigned char *data, int width, int height,
            unsigned char *pal);
        int savebmp1bit(char *fname, unsigned char *data, int width, int height,
            unsigned char *pal);
        </code></pre>
        <P>
        <code>bmpgetinfo</code> - query a bitmap file for its type. It returns the dimensions, and the bit depth (so 2, 4, 8, 16, 24, or 32). Note that 32 bit bitmaps do not have an alpha channel.
        </P>
        <P>
        <code>loadbmp</code> - the function you will normally use. Loads any bitmap as 24 bit RGB data.
        </P>
        <P>
        <code>loadbmp8bit</code> - load a bitmap with its palette. pal should be a buffer of 768 bytes for 256 RGB triplets. The bitmap must have depth of 8 bits.
        </P>
        <P>
        <code>loadbmp4bit</code> - load a 4 bit bitmap with its palette. pal shoule be a buffer
          of 48 bytes for 16 RGB triplets. The bitmap must have a depth of 4 bits. It returns the raster data packed in nybles.
        </P>
        <P>
        <code>savebmp</code> - save a 24 bit RGB image as a bitmap.
        </P>
        <P>
        <code>savebmp8bit</code> - the raster data represents indexes into the palette. which is 256 24-bit RGB entries.
        </P>
        <P>
        <code>savebmp4bit</code> - save a colour-indexed image as a 4 bit bitmap. Note that each byte should be in the rnage 0-15 and represent an idex into the 16 entry palette. The function does not accept raser data packed into nybles.
        </P>
        <P>
        <code>savebmp1bit</code> - save a binary (1-bit) bitmap. Each byte in the raster represents one pixel and must be 1 or 0. The actual colours are determiend by the two-entry palette. This one hasn't been well-tested, and we need a corresponding save routine. Then it can go inthe binaryimage library.'
        </P>

        <HR>
        <H3> csv.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load a comma-separated value file into memory. It attempts to automativally detect the presence of a header. It supports missing values and intricate string escapes, but not non-comma separators. It also determines the type of data in a column.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
            #define CSV_NULL 0       /* null data */
            #define CSV_REAL 1       /* floating-point data */
            #define CSV_STRING 2     /* string data */
            #define CSV_BOOL 3       /* boolean data */

            CSV *loadcsv(const char *fname);
            void killcsv(CSV *csv);
            void csv_getsize(CSV *csv, int *width, int *height);
            int csv_hasdata(CSV *csv, int col, int row);
            double csv_get(CSV *csv, int col, int row);
            const char *csv_getstr(CSV *csv, int col, int row);
            int csv_hasheader(CSV *csv);
            const char *csv_column(CSV *csv, int col, int *type);
        </code></pre>
        <P>
        <code>loadcsv</code> - loads a CSV object from a file. Returns NULL on fail. It needs a rewrite to improve error handling.
        </P>
        <P>
        <code>killcsv</code> - CSV object destructor.
        </P>
        <P>
        <code>csv_getsize</code> - get the dimensions of the CDV dataframe in rows (height) and columns (width).
        </P>
        <P>
        <code>csv_hasdata</code> - you need to call this before every access to check that the CSV file cell is not empty (missing data).
        </P>
        <P>
        <code>csv_get</code> - get numerical data from the CSV object. Note that integers will be returned as doubles.
        </P>
        <P>
        <code>csv_getstr</code> - get string data from the CDV file. The string is owned by the CSV object and shouldn't be hung on to.
        </P>
        <P>
        <code> csv_hasheader</code> - check is the first row of the CSV data is a header.
        </P>
        <P>
        <code>csv_column</code> - query the CSV object for the type of data in a column. Which will be either CSV_REAL or CSV_STRING, except for degenerate csv files with completely empty columns.
        </P>
        <P>
        See <A href="usingcsv.html"> using CSV</A>.
        </P>
        <HR>
        <H3> dumpcsv.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to convert a CSV object into C source. If the CSV file is a matrix then the data is written out as a two-dimensional array. Otheerwise it is written out as a dataframe, an array of C structs. The struct field names are determined from the CSV file header.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        int dumpcsv(FILE *fpout, int headerfile, const char *name, CSV *csv);
        </code></pre>
        <P>
        <code>dumpcsv</code> - convert a CSV object to C source code. headerfile means write out a C header file instead of a .c source file (the word "header" would have ben confusing). It should be considered experimental.
        </P>
        <HR>
        <H3> gif.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load or save a .GIF image. It depends on rbtree.c and rbtree.h.
        </P>
        <pre><code class="language-c">
            unsigned char *loadgif(char *fname, int *width, int *height,
                unsigned char *pal, int *transparent);
            int savegif(char *fname, unsigned char *data, int width, int height,
                unsigned char *pal, int palsize, int transparent, int important,
                int interlaced);
        </code></pre>
        <P>
        <code>loadgif</code> - load a non-animated GIF file. pal should point to 768 byters for 256 RGB triplets. transparent gives the index of the transparent colour (-1 if none, which is quite common).
        </P>
        <P>
        <code>savegif</code> - save a non-animated GIF file. This one looks frightening, because of little-used features of GIF files we support. pal points to palsize RGB triplets. transparent passes in the transparent color (use -1 for no transparency). important and interlaced are obsolete and can be zero.
        </P>
        <HR>
        <H3> jpeg.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load a JPEG image as a 24-bit rgb array.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        unsigned char *loadjpeg(const char *path, int *width, int *height);
        </code></pre>
        <P>
        <code>loadjpeg</code> - load a JPEG.
        </P>
        <HR>
        <H3> loadasutf8.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load practically any common text format file as clean UTF-8 without a BOM. It relies on automatic detection of text format type.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        char *loadasutf8(const char *filename, int *err);
        </code></pre>
        <P>
        <code>loadasutf8</code> - load text as UTF-8. It's quite straightforwards except for the text format detection code on which it depends. It returns NULL and err is set to non-zero on failure. To do, improve error reporting.
        </P>
        <HR>
        <H3> loadcursor.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to load a Microsoft .cur (cursor) file.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        typedef struct
        {
            int width;
            int height;
            unsigned char *rgba;
            int hotx;
            int hoty;
        } BBX_CURSOR;

        BBX_CURSOR *loadcursor(const char *filename, int *err);
        </code></pre>
        <P>
        <code>loadcursor</code> - load a .cur file. A .cur file is basically just a bitmap with a hotpoint attached. The function hasn't been well-tested.
        </P>
        <HR>
        <H3> loadimage.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        High-level image loading function. Should load practically anything as 32 bit RGBA, including SVG files.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        unsigned char *loadrgba(char *fname, int *width, int *height, int *err);
        unsigned char *loadassvgwithsize(char *fname, int width, int height);
        </code></pre>
        <P>
        <code>loadrgba</code> - load a raster image (.bmp, .gif, .jpeg, .png, .tiff) as a 32 bit RGBA. We try to keep to the convention  that err -1 means out of memory, -2 means failure to open file or Io error, and -3 means a parse error. However it's unlikely that this is completely consistent. This is the crown jewel function.
        </P>
        <P>
        <code>loadsvg</code> - load an SVG as a 32 bit RTGBA raster. Since SVGs are scaleable, they can't have the same interface as the raster graphics, and you have to pass in the width and height that you want.
        </P>
        <HR>
        <H3> loadmp3.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        A thin layer on top of the minimp3.c audio decoder to load an MP3 file into memory as raw uncompressed audio 16-bit PCM samples.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        short *loadmp3(const char *fname, long *samplerate, int
                       *Nchannels, long *Nsamples);
        short *mp3streamdecompress(unsigned char *mp3_stream, int stream_size,
           long *samplerate, int *Nchannels, long *Nsamples);
        </code></pre>
        <P>
        <code>loadmp3</code> - loads an MP3 file using the same interface as for WAV and AIFF files.
        </P>
        <P>
        <code>mp3streamdecompress</code> - a function to decompress and entire MP3 image in one go. It's useful for audio processing, less useful for playback.
        </P>
        <HR>
        <H3> loadtiff.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        TIFF file loader. TIFF is one of those formats which has been allowed to get out of control. However this function will load the vast majority of TIFFs.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        unsigned char *floadtiff(FILE *fp, int *width, int *height);
        </code></pre>
        <P>
        <code>floadtiff</code> - load a TIFF froman open stream. TIFFs were designed to work with non-seekable streams, hence the interface. TIFF is a very complicated umbrella format and it will probably fail on some input.
        </P>
        <HR>
        <H3> lodepng.c </H3>
        <P> <B>Copyright:</B> (c) 2005-2012 Lode Vandevenne
        <P>
        PNG (Portable network graphic) file loader and saver.
        </P>
        <HR>
        <H3> minimp3.c </H3>
        <P>
        <B>Copyright:</B> (c) 2001, 2002 Fabrice Bellard, <BR>
        <B>Copyright:</B> (c) 2007 Martin J. Fiedler
        </P>
        <P>
        MP3 audio decoder. This is almost in a single file (there is a trivial dependency on libc.h), and is a great achievement.
        </P>
        <HR>
        <H3> options.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Commandline options parser.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        OPTIONS *options(int argc, char **argv, char *flags);
        void killoptions(OPTIONS *opt);
        int opt_get(OPTIONS *opt, char *name, char *fmt, ...);
        int opt_error(OPTIONS *opt, FILE *fp);
        int opt_Nargs(OPTIONS *opt);
        char *opt_arg(OPTIONS *opt, int index);
        </code></pre>
        <P>
        <code>options</code> - create an OPTIONS object from argc and argv. It takes local copies, so everything is from thsi point self-contained. flags is a list of sigle character flags the options parser will accept. If you don't support single character option flags, pass NULL rather than the empty string.
        </P>
        <P>
        <code>killoptions</code> - the OPTIONS object destructor.
        </P>
        <P>
        <code>opt_get</code> - query the OPTIONS object for an option. You can pass several aliases for an option at once, eg, "-help -h --help /help /h". If the option is a flag, fmt should be null. If it takes arguments, it's similar to scanf() - pass %d for an integer or %f for a double. %s should always take a length field (e.g %256s) to avoid buffer overruns. Intitialise the arguments to defaults and they will not be overwritten if the option is not present. Note that opt_get() is used both to extract options, and to tell the options parser what the allowed options are. So you must query for every option you support.
        </P>
        <P>
        <code>opt_error</code> - query the options parser for user errors. Pass a stream to receive error text (so, usually, pass stderr), or NULL to suppress. It returns non-zero if there is an error. The main errors are unrecognised options, or options with the wrong arguments. So setting up the opt_get calls beforehand is vital. Note that it won't sanity check arguments for you, you have to do that in caller.
        </P>
        <P>
        <code>opt_Nargs</code> - after all the calls to opt_get have been completed, the remaining arguments in argv are non-option arguments, usually filenames. This function counts them.
        </P>
        <P>
        <code>opt_arg</code> - call to retrieve non-option arguments. The arguments are allocated with malloc() and so should be freed by caller.
        </P>
        <P>
        See <A href="usingoptions.html"> using the commandline options parser</A>.
        </P>
        
        <HR>
        <H3> rbtree.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to implement a red-black tree. red-black trees are balanced binary trees which do not deenrate into linked lists afte rrepeated insertions or deletions. They always remain reaonsably balanced. Which means that they can offer O(log N) searching of dynamic data.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        RBTREE *rbtree(int (*compfunc)(const void *e1, const void *e2));
        void killrbtree(RBTREE *tree);
        int rbt_add(RBTREE *tree, void *key, void *data);
        int  rbt_del(RBTREE *tree, void *key);
        void *rbt_find(RBTREE *tree, void *key);
        void *rbt_next(RBTREE *tree, void *key, void **dataret);
        void *rbt_prev(RBTREE *tree, void *key, void **dataret);
        </code></pre>
        <P>
        <code>rbtree</code> - constructor for an empty RBTREE object. Since the tree is sorted, it need s aqsort-style comparison function to order the elements.
        </P>
        <P>
        <code>killrbtree</code> - RBTREE destructor. Note that it doesn't own its contents.
        </P>
        <P>
        <code>rbt_add</code> - add an entry to the RBTREE. It consists of a key / data item pair. The RBTREE doesn't own the keys or the data, so the key can be a field of the data entry.
        </P>
        <P>
        <code>rbt_del</code> - delete an entry from the tree. Returns -1 if the object is not found. Note that it won't delete either the key or the data.
        </P>
        <P>
        <code>rbt_find</code> - search for an entry by key. It returns a pointer to the data item if found, NULL if not found.
        </P>
        <P>
        <code>rbt_next</code> - for "walking" the tree. Returns the key for the next entry, and fills in the void ** for the data. Pass NULL for the first entry, and then the return for the subsequent entries, until the function returns NULL.
        </P>
        <P>
        <code>rbt_prev</code> - for "walking" the tree in a reverse direction. Returns the key for the previous entry, and fills in the void ** for the data. Pass NULL for the last entry, and then the return for the preceding entries, until the function returns NULL.
        </P>
        <P>
        See <A href="usingrbtree.html"> using the RBTREE</A>.
        </P>
        <HR>
        <H3> resize.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to resize images.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        void resizeimage(unsigned char *dest, int dwidth, int dheight,
            unsigned char *src, int swidth, int sheight);
        </code></pre>
        <P>
        <code>resizeimage</code> - resize a 32 bit RGBA image to dwidth, dheight. It doesn't allocate the buffer so you have to pass it in.
        </P>
        <HR>
        <H3> savejpeg.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
    
        <P>
        JPEG saver. There's no facility for choosing quality, and it just uses generally accepted defaults. However you can play with the quantisation table if you want.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        int savejpeg(char *path, unsigned char *rgb, int width, int height);
        </code></pre>
        <P>
        <code>savejpeg</code> - saves a JPEG. There are no options for quality. If you want to add them. you will need to adjust the quantisation table.
        <HR>
        <H3> text_encoding_detect.c </H3>
        <P> <B>Copyright:</B> 2015 Jonathan Bennett </P>
        <P>
        Code to automatically detect text format form the binary.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        typedef enum
        {
            TEXTENC_None,                // Unknown or binary
            TEXTENC_ANSI,                // 0-255
            TEXTENC_ASCII,               // 0-127
            TEXTENC_UTF8_BOM,            // UTF8 with BOM
            TEXTENC_UTF8_NOBOM,          // UTF8 without BOM
            TEXTENC_UTF16_LE_BOM,        // UTF16 LE with BOM
            TEXTENC_UTF16_LE_NOBOM,      // UTF16 LE without BOM
            TEXTENC_UTF16_BE_BOM,        // UTF16-BE with BOM
            TEXTENC_UTF16_BE_NOBOM,      // UTF16-BE without BOM
        } TextEncoding;

        TextEncoding DetectTextFileEncoding(const char *filename, int *error);

        </code></pre>
        <P>
        <code>DetectTextFileEncoding</code> - this uses very good heuristics. error isn't really functional.
        </P>
        <HR>
        <H3> ttf2c.c </H3>
        <P>
        <B>Copyright:</B> Malcolm McLean
        </P>
        <P>
        This is a thin layer on top of the freetype/ code which loads a .ttf or TrueType font, and saves it out as a struct bitmap_font.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        int dumpttf(char *fname, int header, char *name, int points, FILE *fp);
        </code></pre>
        <P>
        <code>dumpttf</code> - write out a TrueType font as C source for a bitmap_font structure. You need to pass in the size you want in points. fp points to the output stream. header is set to just output a C header.
        </P>
        <HR>
        <H3> wavfile.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Microsoft .wav file loader and saver. WAV files are relatively simple and clean.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        short *loadwav(const char *fname, long *samplerate, int *Nchannels, long
            *Nsamples);
        int savewav(const char *fname, const short *pcm, long samplerate, int
            Nchannels, long Nsamples);
        short *floadwav(FILE *fp, long *samplerate, int *Nchannels, long
            *Nsamples);
        int fsavewav(FILE *fp, const short *pcm, long samplerate, int Nchnanels,
            long Nsamples);
        </code></pre>
        <P>
        <code>loadwav</code> - load a WAV file.
        </P>
        <P>
        <code>savewav</code> - save a WAV file.
        </P>
        <P>
        <code>floadwav</code> - load a WAV file from an open stream.
        </P>
        <P>
        <code>fsavewav</code> - save a WAV file to an open stream.
        </P>
        <HR>
        <H3> xmlparser.c </H3>
        <P> <B>Copyright:</B> Malcolm McLean </P>
        <P>
        Code to parse an XML file. Whilst it is adequate for parsing Baby X resource compiler input files, it is not good enough to stand up to use as a general XML file parser.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        typedef struct xmlattribute
        {
            char *name;                /* attribute name */
            char *value;               /* attribute value (without quotes) */
            struct xmlattribute *next; /* next pointer in linked list */
        } XMLATTRIBUTE;

        typedef struct xmlnode
        {
            char *tag;                 /* tag to identify data type */
            XMLATTRIBUTE *attributes;  /* attributes */
            char *data;                /* data as ascii */
            int position;              /* position of the node within parent's
                                            data string */
            struct xmlnode *next;      /* sibling node */
            struct xmlnode *child;     /* first child node */
        } XMLNODE;

        typedef struct
        {
            XMLNODE *root;             /* the root node */
        } XMLDOC;


        XMLDOC *loadxmldoc(char *fname, int *err);
        XMLDOC *floadxmldoc(FILE *fp, int *err);
        void killxmldoc(XMLDOC *doc);

        XMLNODE *xml_getroot(XMLDOC *doc);
        const char *xml_gettag(XMLNODE *node);
        const char *xml_getdata(XMLNODE *node);
        const char *xml_getattribute(XMLNODE *node, const char *attr);
        int xml_Nchildren(XMLNODE *node);
        int xml_Nchildrenwithtag(XMLNODE *node, const char *tag);
        XMLNODE *xml_getchild(XMLNODE *node, const char *tag, int index);
        XMLNODE **xml_getdescendants(XMLNODE *node, const char *tag, int *N);
        </code></pre>
        <P>
        <code>loadxmldoc</code> - load an XML document.
        </P>
        <P>
        <code>floadxmldoc</code> - load an XML document from an open stream.
        </P>
        <P>
        <code>killxmldoc</code> - XMLDOC destructor.
        </P>
        <P>
        <code>xml_getroot</code> - get the root node of the XML document. All other nodes are descendants.
        </P>
        <P>
        <code>xml_gettag</code> - get the element name associated with a node.
        </P>
        <P>
        <code>xml_getdata</code> - get the data (the text between the open and close tags) associated with a node. Note currrently this function doesn't handle properly nodes with both children and embedded text.
        </P>
        <P>
        <code>xml_getattribute</code> - get the named atribute data associated with a node. You have to walk the attribute list to query for unknown attributes(which should be rarely needed).
        </P>
        <P>
        <code>xml_getNchildren</code> - get the number of direct children of a node.
        </P>
        <P>
        <code>xml_Nchildrenwithtag</code> - convenience function, get the number of children with a given element name.
        </P>
        <P>
        <code>xml_getchild</code> - get the child of a node, passing in element name and index. So use in conjunction with xml_Nchildrenwithtag() to visi every child element of a given type. Note that this function starts from the beginning of the list on each call, don't use for really long XML (walk the list by hand). If you pass NULL for the element name, it finds he Nth child of any type.
        </P>
        <P>
        <code>xml_getdescendants</code> - convenience function. it gets all the descendants of a node with a certain element name, and returns them in an allocated list. Useful for over-specified XML where the data of interest is buried away in higher-level structures.
        </P>
        <P>
        The XML parser is being rewritten and is not advised for general use at present. It's good enough for simple XML like the Baby X resource script, but it won't stand up to the complications found in general XML.
        </P>
        <P>
        See <A href="usingxmlparser.html">using the XML parser</A>.
        </P>
        <HR>
        <H3> nanosgv.h </H3>
        <P> <B>Copyright:</B> (c) 2013-14 Mikko Mononen
        <P>
        This code is implemented as header-only file. It parses an SVG (scaleable vector graphics) file.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
        void nsvgDelete(NSVGimage* image);
        </code></pre>
        <HR>
        <H3> nanosvgrast.h </H3>
        <P> <B>Copyright:</B> (c) 2013-14 Mikko Mononen
        <P>
        This code is implemented as a header-only file. It takes the output of nanosvg.h, and produces a raster image.
        </P>
        <H4> Public functions</H4>
        <pre><code class="language-c">
        NSVGrasterizer* nsvgCreateRasterizer(void);
        void nsvgDeleteRasterizer(NSVGrasterizer* r);
        void nsvgRasterize(NSVGrasterizer* r,
                           NSVGimage* image, float tx, float ty, float scale,
                           unsigned char* dst, int w, int h, int stride);
        </code></pre>
        <HR>
        <H3> freetype/ </H3>
        <P> <B>Copyright:</B> 1996-1999 by David Turner, Robert Wilhelm, and Werner Lemberg. </P>
        <P>
        This directory contains files for drawing TrueType fonts. We use it to convert the fonts to a simple raster representation which can be used by small programs.
        </P>
        <HR>
        <H3> samplerate/ </H3>
        <P> <B> Copyright:</B> (C) 2002-2011 Erik de Castro Lopo </P>
        <P>
        This directory contains files for resampling audio at a given frequency (Hz).
        </P>
</BODY>
</HTML>
